<?php
/**
 * Created by PhpStorm.
 * User: ls721
 * Date: 2016/11/27 0027
 * Time: 15:58
 */class Domain_pushMessage{

    public function sendMQTT($target,$message){
        $conn = new SAMConnection();

//start initialise the connection
        $conn->connect(SAM_MQTT, array('127.0.0.1','1883'));

//create a new MQTT message with the output of the shell command as the body
        $msgCpu = new SAMMessage($message);

//send the message on the topic cpu
        $conn->send('topic://'.$target, $msgCpu);

        $conn->disconnect();
    }
}